package com.feature.shop.user.converter;

import java.util.List;

import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import com.feature.core.config.MapstructTypeConvert;
import com.feature.shop.user.api.request.ShopMenuListRequest;
import com.feature.shop.user.api.request.ShopMenuPageRequest;
import com.feature.shop.user.api.vo.ShopMenuVo;
import com.feature.shop.user.api.vo.ShopTreeMenuVo;
import com.feature.shop.user.model.entity.ShopMenuEntity;
import com.feature.shop.user.model.query.ShopMenuQuery;

/***
 * 菜单表Converter
 */
@Mapper(uses = MapstructTypeConvert.class)
public interface ShopMenuConverter {

    @Named("entityToVO")
    ShopMenuVo entityToVO(ShopMenuEntity entity);

    @Named("entityToTreeMenuVO")
    @Mapping(target = "children", ignore = true)
    ShopTreeMenuVo entityToTreeMenuVO(ShopMenuEntity entity);

    @IterableMapping(qualifiedByName = "entityToVO")
    List<ShopMenuVo> entityListToVO(List<ShopMenuEntity> list);

    @IterableMapping(qualifiedByName = "entityToTreeMenuVO")
    List<ShopTreeMenuVo> entityListToTreeMenuVO(List<ShopMenuEntity> list);

    ShopMenuQuery pageRequestToQuery(ShopMenuPageRequest request);

    ShopMenuQuery listRequestToQuery(ShopMenuListRequest request);

}
